-----------------------------------------------------------------------
-- File:        Blocks.ads
-- Description: Provides an interface to the hardware control of blocks,
--		    calls procedures that set the Cab and polarity of a block,
--              that init blocks and flip the polarity of a block. It also
--              provides block acquiring and release functionality
--
-- Requires:    Io_Ports,Unsigned_Types,Raildefs,Dio192defs, Dda06defs,
--              Int32defs
--				
-- Author:     Maria Mitrevska
-----------------------------------------------------------------------
with Io_Ports;
with Unsigned_Types;
use Unsigned_Types;  -- 1.8
with Raildefs,
   Dio192defs, Dda06defs, Int32defs;
use Raildefs;


package Blocks is --PROTECTED

   -- Init Blocks
   procedure Init_Block;

   -- Acquare a Block
   --It returns Success=true if the train has acquired the block
   --It returns Success=false if another train owns the block
   procedure Acquire_Block (
         Success :    out Boolean;
         Train   : in     Raildefs. Train_Id;
         B       : in     Raildefs. Block_Idx);

   --Release a block
   --It returns Success=true if the train has released the block
   procedure Release_Block (
         Success :    out Boolean;
         Train   : in     Raildefs. Train_Id;
         B       : in     Raildefs. Block_Idx);


   --Sets Cab and Polarity of a Block by calling Dio192_Blocks.Set_Cab
   -- and Dio192_Blocks.Set_Polarity
   procedure Set_Block (
         Success :    out Boolean;
         Train   : in     Raildefs. Train_Id;
         B       : in     Raildefs.Block_Id;
         Cab     : in     Raildefs.Cab_Type;
         Pol     : in     Raildefs.Polarity_Type);

   --Reverse polarity of a Block by calling Dio192_Blocks.Flip_Block
   procedure Reverse_Block (
         Success :    out Boolean;
         Train   : in     Raildefs. Train_Id;
         B       : in     Raildefs.Block_Id);

end Blocks;